
import flash.MovieClip;

class Clock {
        // creates a TextField         
    static function main() {
     var mc = flash.Lib.current;
     var bg = mc.attachMovie("bg-fish", "bg-fish", 0);
         bg._x = 0;
         bg._y = 0;

     var lastTime : Float = 0;

     var fontSize : Float = 90;
     var fontName : String = "minya";
     
     var clockFgFormat = new flash.TextFormat();
     clockFgFormat.font = fontName;
     clockFgFormat.size = fontSize;
     clockFgFormat.color = 0xFFFFFF;
     var clockShdwFormat = new flash.TextFormat();
     clockShdwFormat.font = fontName;
     clockShdwFormat.size = fontSize;
     clockShdwFormat.color = 0x666666;
     var clockTxt = mc.createTextField("clockTxt", 10000, 16, 80, 300, 200);
     var clockShdwTxt = mc.createTextField("clockShdwTxt", 9000, 18, 82, 300, 200);
     clockTxt.selectable = false;
     clockTxt.embedFonts = true;
     clockTxt.setNewTextFormat(clockFgFormat);
     mc.addChild(clockTxt);
  
     /*
  var format = new flash.TextFormat();
format.font = "minya";
format.size = 40;
format.color = 0x000000;

     clockTxt.embedFonts = true;
clockTxt.setNewTextFormat(format);
     clockTxt.text = "Hello World !";
mc.addChild(clockTxt);
     */
     clockShdwTxt.selectable = false;
     clockShdwTxt.embedFonts = true;
     clockShdwTxt.setNewTextFormat(clockShdwFormat);
     mc.addChild(clockShdwTxt);
     
     mc.onEnterFrame = function(){
        var now = Date.now();
        if(lastTime==null || (now.getTime() - lastTime) > 500){

	  var separator = ":";
//          if(now.getSeconds() % 2 == 0){
//            separator = " ";
//	  }

          var timeTxt = now.getHours() + separator
                       + (now.getMinutes()< 10 
                            ? "0"+Std.string(now.getMinutes()): Std.string(now.getMinutes()));
          clockTxt.text = timeTxt;
          clockShdwTxt.text = timeTxt;
          clockTxt.setTextFormat(clockFgFormat);
          clockShdwTxt.setTextFormat(clockShdwFormat);
          lastTime = now.getTime();  
        }
     
     }
   
    }

 
}
